package com.crazymaker.springcloud.standard.lua;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

@Slf4j
public class ScriptHolder {

    /**
     * 加载限流脚本
     * @param url
     * @return
     */
    public static String loadRateLimitLua(String url) {
        ClassPathResource pathResource = new ClassPathResource(url);
        try {
            return IOUtils.toString(pathResource.getInputStream());
        } catch (IOException e) {
            log.error("{} not found", url, e);
        }
        return null;
    }
}
